import { notification, message } from 'antd';
import cloneDeep from 'lodash/cloneDeep';
import _map from 'lodash/map';
import _uniq from 'lodash/uniq';
import _pull from 'lodash/pull';
import { GetDateThree, FormatnumberZero } from '../../../../function';
import {
  getOptionLong, getOptionShortBp, getOptionShortSc,
  getStockAllPositionShort, getStockAllPositionLong, getExposureTable
} from '../../../../services/allposition2_service';
import { delExchange } from '../../../../services/foreignExchange_service';

export default {
  namespace: 'slpandect',
  state: {},

  effects: {
    *GetOptionLong({ payload, callback }, { call, put }) {
      const response = yield call(getOptionLong, payload);
      if (typeof response === 'undefined') {
        return;
      }
      if (typeof response !== 'undefined' && response.code === 1) {
        if (callback) callback(response);
      } else {
        notification.error({
          message: typeof response.message !== 'undefined' ? response.message : '请求错误',
        });
      }
    },
    *GetOptionShortBp({ payload, callback }, { call, put }) {
      const response = yield call(getOptionShortBp, payload);
      if (typeof response === 'undefined') {
        return;
      }
      if (typeof response !== 'undefined' && response.code === 1) {
        if (callback) callback(response);
      } else {
        notification.error({
          message: typeof response.message !== 'undefined' ? response.message : '请求错误',
        });
      }
    },
    *GetOptionShortSc({ payload, callback }, { call, put }) {
      const response = yield call(getOptionShortSc, payload);
      if (typeof response === 'undefined') {
        return;
      }
      if (typeof response !== 'undefined' && response.code === 1) {
        if (callback) callback(response);
      } else {
        notification.error({
          message: typeof response.message !== 'undefined' ? response.message : '请求错误',
        });
      }
    },
    *GetExposureTable({ payload, callback }, { call, put }) {
      const response = yield call(getExposureTable, payload);
      if (typeof response === 'undefined') {
        return;
      }
      if (typeof response !== 'undefined' && response.code === 1) {
        if (callback) callback(response);
      } else {
        notification.error({
          message: typeof response.message !== 'undefined' ? response.message : '请求错误',
        });
      }
    },
   *GetStockAllPositionLong({ payload, callback }, { call, put }) {
        const response = yield call(getStockAllPositionLong, payload);
        if (typeof response === 'undefined') {
          return;
        }
        if (typeof response !== 'undefined' && response.code === 1) {
          if (callback) callback(response);
        } else {
          notification.error({
            message: typeof response.message !== 'undefined' ? response.message : '请求错误',
          });
        }
      },
   *GetStockAllPositionShort({ payload, callback }, { call, put }) {
        const response = yield call(getStockAllPositionShort, payload);
        if (typeof response === 'undefined') {
          return;
        }
        if (typeof response !== 'undefined' && response.code === 1) {
          if (callback) callback(response);
        } else {
          notification.error({
            message: typeof response.message !== 'undefined' ? response.message : '请求错误',
          });
        }
      },
  },

  reducers: {},
};
